package what.basic.table;
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.table.*;

import java.awt.event.*;
import what.basic.basiccomponent.*;
public class Jtablewithcolumnwidth {
Jtablewithcolumnwidth(){
	
	Jframe jf=new Jframe();
	JFrame f=jf.jframe("",300,300,true);
	Object[][] st={
			{"wangpeng",new Integer(91),new Integer(100)}
			,{"zhuxuelian",new Integer(82),new Integer(69)},
			{"meiting",new Integer(47),new Integer(57)},
	};
	String[] names={"name","yuwen","shuxue"};
	JTable table=new JTable(st,names);
	table.setPreferredScrollableViewportSize(new Dimension(550,30));
	//JScrollPane sp=new JScrollPane(table);
	f.getContentPane().add(table,BorderLayout.CENTER);
	f.getContentPane().add(table.getTableHeader(),BorderLayout.NORTH);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
	for(int i=0;i<3;i++){
		TableColumn col;
		col=table.getColumnModel().getColumn(i);
		if((i%2)==0)
			col.setPreferredWidth(100);
		else
			col.setPreferredWidth(50);
	}
	f.setTitle("table test window");
	f.pack();
}
public static void main(String[] args) {
	new Jtablewithcolumnwidth();
	}

}
